import { createParamDecorator, ExecutionContext } from '@nestjs/common';
import { Request } from 'express';

export const CurrentUser = createParamDecorator(
  (data = '', context: ExecutionContext) => {
    const ctx = context.switchToHttp();
    const usr = ctx.getRequest<Request>().user;
    return usr?.[data] || usr;
  },
);
